package com.xyy.saas.payment.controller;

import com.alibaba.fastjson.JSONObject;
import com.xyy.saas.payment.pojo.vo.PayCheckVo;
import com.xyy.saas.payment.manage.cores.vo.ResultPageVo;
import com.xyy.saas.payment.service.PayCheckService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 支付对账界面
 */
@RestController
@RequestMapping("/payCheck")
@Slf4j
public class PayCheckController {

    @Autowired
    private PayCheckService payCheckService;

    @PostMapping(value = "/query",produces = "application/json;charset=utf-8")
    @ResponseBody
    public String query(@RequestBody String jsonStr){
        log.info("查询支付对账信息参数:{}",jsonStr);
        ResultPageVo<List<PayCheckVo>> result = payCheckService.queryByPage(jsonStr);
        return JSONObject.toJSONString(result);
    }

    @PostMapping(value = "/export")
    public void reportExportOrder(@RequestBody String jsonStr,
                                  HttpServletRequest request,
                                  HttpServletResponse response) {
        log.info("导出对账界面数据:{}",jsonStr);
        payCheckService.export(jsonStr, request, response);
    }
}
